﻿<controls:ChildWindow x:Class="RIAExample.Views.EdicaoProduto"
           x:Name="ChildWindowEdicaoProduto"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                      
           xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
           
           Width="400" Height="300" 
           Title="EdicaoProduto">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <toolkit:DataForm Name="DataForm"                               
                Header="Novo Produto"
                AutoGenerateFields="False"
                AutoCommit="False"            
                AutoEdit="True"                            
                CommitButtonContent="Salvar" 
                CommandButtonsVisibility="Commit"
                CurrentItem="{Binding Produto, ElementName=ChildWindowEdicaoProduto}"
                EditEnded="DataForm_EditEnded" ContentLoaded="DataForm_ContentLoaded">
            <toolkit:DataForm.EditTemplate>
                <DataTemplate>
                    <StackPanel>
                        <toolkit:DataField Label="Descrição:" Description="Descrição do Produto">
                            <TextBox x:Name="txtDescricao" Text="{Binding Descricao, Mode=TwoWay}" />
                        </toolkit:DataField>
                        <toolkit:DataField Label="Preço:" Description="Preço do Produto">
                            <TextBox x:Name="txtPreco" Text="{Binding Preco, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=False}" />
                        </toolkit:DataField>
                        <toolkit:DataField Label="Supermercado" Description="Supermercado vinculado">
                            <ComboBox x:Name="cbxSupermercado" 
                                      DisplayMemberPath="Nome" 
                                      SelectedValuePath="SupermercadoID"
                                      SelectedValue="{Binding SupermercadoID, Mode=TwoWay}" />
                        </toolkit:DataField>
                    </StackPanel>
                </DataTemplate>
            </toolkit:DataForm.EditTemplate>
        </toolkit:DataForm>
    </Grid>
</controls:ChildWindow>